package org.scohen.juploadr.uploadapi.flickrrest.tags;

import java.util.LinkedList;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;

import org.scohen.juploadr.app.tags.Tag;
import org.scohen.juploadr.uploadapi.ProtocolException;
import org.scohen.juploadr.uploadapi.flickrrest.DefaultFlickrHandler;
import org.scohen.juploadr.uploadapi.flickrrest.FlickrMethod;
import org.scohen.juploadr.uploadapi.flickrrest.RestFlickrApi;
import org.scohen.juploadr.uploadapi.flickrrest.UserNotFoundException;

public class GetListUser extends FlickrMethod {
    private List<Tag> tags;
    
    public GetListUser() {
        this.tags = new LinkedList<Tag>();
    }
    
    public DefaultFlickrHandler getResponseHandler() {
        return new GetListUserHandler(this);
    }

    public SortedMap<String, String> getParams() {
        SortedMap<String, String> params = new TreeMap<String, String>();
        params.put("method","flickr.tags.getListUser");
        params.put("api_key",RestFlickrApi.FLICKR_API_KEY);
        return params;
    }

    public boolean isAuthorized() {
        return true;
    }
    
    public void addTag(String tag) {
       tags.add(new Tag(tag)); 
    }
    
    public List getTags() {
        return tags;
    }

    @Override
    protected ProtocolException buildProtocolException(int errorCode) {
        if ( errorCode == 1) {
            return new UserNotFoundException();
        }
        return null;
    }
    
    

}
